home *** CD-ROM | disk | FTP | other *** search
- /* setf.e -- a SnoopDos-like program to monitor calls to OpenLibrary() */
-
- OPT OSVERSION=37
-
- MODULE 'dos/dos', 'exec/ports', 'exec/tasks', 'exec/nodes', 'exec/memory'
- MODULE 'graphics/rastport'
-
- /* "port" will be used from the patched routine, too, so it's global */
- DEF port:PTR TO mp
-
- CONST SCROLLRASTER = $fe74
-
- /* You can change the library function to be patched by changing OFFSET
- and the "execbase" in the *two* calls to SetFunction(). If you want to
- patch a library other than dos, exec, graphics and intuition you need
- to OpenLibrary() it first.
- (Note: some [old?] libraries cannot be patched in this way. Also, some
- functions in some libraries can't be patched like this either! Even the
- RKRM's aren't too clear about this...)
- */
- PROC main()
- DEF oldf
-
- IF port:=CreateMsgPort()
- Forbid() /* Don't let anyone mess things up... */
- IF oldf:=SetFunction(gfxbase, SCROLLRASTER, {newf})
- PutLong({patch}, oldf)
- Permit() /* Now we can let everyone else back in */
- LEA store(PC), A0
- MOVE.L A4, (A0) /* Store the A4 register... */
- Wait(SIGBREAKF_CTRL_C)
- Forbid() /* Paranoid... */
- SetFunction(gfxbase, SCROLLRASTER, oldf)
- ENDIF
- Permit()
- DeleteMsgPort(port)
- ELSE
- PutStr('Unable to create message port\n')
- ENDIF
- ENDPROC
-
- PROC myscrollraster() ->rp_ptr:PTR TO rastport, deltax, deltay, x, y, x2, y2)
- DEF rp_ptr:rastport, deltax, deltay, x, y, x2, y2
- DEF rpx, rpy, rpx2, rpy2, width, height
-
- /* DEF tsk:tc, l:ln
-
- tsk := FindTask(NIL)
-
- IF tsk THEN l:=tsk.ln */
-
- MOVE.L A1, rp_ptr
- MOVE.L D0, deltax
- MOVE.L D1, deltay
- MOVE.L D2, x
- MOVE.L D3, y
- MOVE.L D4, x2
- MOVE.L D5, y2
-
- IF (deltax >= 0)
- rpx := x + deltax
- rpx2 := x
- width := (-x + (x2 + 1)) - deltax
- ELSE
- rpx := x
- rpx2 := x - deltax
- width := (-x + (x2 + 1)) + deltax
- ENDIF
-
- IF (deltay >= 0)
- rpy := y + deltay
- rpy2 := y
- height := (-y + (y2 + 1)) - deltay
- ELSE
- rpy := y
- rpy2 := y - deltay
- height := (-y + (y2 + 1)) + deltay
- ENDIF
-
- ClipBlit(rp_ptr, rpx, rpy,
- rp_ptr, rpx2, rpy2,
- width, height,
- $0C0)
- ENDPROC
-
-
- /* Place to store A4 register */
- store: LONG 0
- /* Place to store real call */
- patch: LONG 0
-
- /* The new routine which will replace the original library function */
- newf:
- MOVEM.L D0-D7/A0-A6, -(A7)
- LEA store(PC), A0
- MOVE.L (A0), A4 /* Reinstate the A4 register so we can use E code */
- myscrollraster()
- MOVEM.L (A7)+, D0-D7/A0-A6
- ->MOVE.L patch(PC), -(A7)
- RTS
-